Skip to content

Simplify default config_name and job_cls mechanism#366

Merged
lesteve merged 6 commits into
dask:masterfrom
lesteve:simplify-config-name
Nov 21, 2019
Merged

Simplify default config_name and job_cls mechanism#366
lesteve merged 6 commits into
dask:masterfrom
lesteve:simplify-config-name

Conversation

@lesteve

@lesteve lesteve commented Nov 19, 2019

Copy link
Copy Markdown
Member

Supersedes and closes #361.
Fixes #358.

The idea is to use a similar mechanism for config_name and job_cls (a class variable is the default value, but it can also be passed as a parameter).

There are also some cleaning up of a few quirks that remained after #307.

@lesteve lesteve changed the title Simplify config name Simplify default config_name and job_cls mechanism Nov 19, 2019

@guillaumeeb guillaumeeb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, this made me a headache to properly understand all the implications here.
I've no strong opinion on this one. I feel it makes the code a little more complex, but this is probably cleaner and may avoid some issues in the future.

Comment thread dask_jobqueue/core.py Outdated
if config_name is None:
config_name = getattr(type(self), "config_name")
if config_name is None:
default_config_name = getattr(type(self), "config_name", None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand why this is needed?
Why don't we just test if self.config_name is None?

Comment thread dask_jobqueue/core.py
self.status = "created"

default_job_cls = getattr(type(self), "job_cls", None)
self.job_cls = default_job_cls

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, not sure to understand, but I probably lack some understanding of Python.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think I understand seeing you've deleted the class attribute job_cls from JobQueueCluster.
I'm not sure this helps, I still need some insights of why you prefer it this way.

Comment thread dask_jobqueue/core.py Outdated
"- set the 'config_name' class variable to a non-None value\n"
"- create a section in jobqueue.yaml with the value of 'config_name'\n"
"If that is not the case, please open an issue in https://github.com/dask/dask-jobqueue/issues."
"Nope your job class needs to have a config_name class attribute"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this comment is better?

Comment thread dask_jobqueue/core.py Outdated
if config_name:
if interface is None:
interface = dask.config.get("jobqueue.%s.interface" % config_name)
default_config_name = getattr(self.job_cls, "config_name", None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the key is here, all the informaton is in the Job class, not in the JobQueueCuster one.

@lesteve

lesteve commented Nov 19, 2019

Copy link
Copy Markdown
Member Author

Okay, this made me a headache to properly understand all the implications here.

I agree this is the kind of PR where it may be easier to look at the code, rather than the diff, because the diff is quite tricky to follow.

My thinking behind this was to simplify the default value mechanism for both job_cls and config_name. Now they are both coming from a class variable (job_cls is a class variable in *Cluster and config_name is a class variable in *Job). Also the *Cluster uses the *Job default config_name. The fact that config_name passed in *Cluster was not the same than the one in *Job was the root cause of #358.

Previously (i.e. in master before this PR is merged):

  • config_name was a class variable in *Cluster objects but not used. What was used was the default value of config_name in the *Job.__init__.
  • default config_name was from default value in *Job.__init__ but default job_cls was in *Cluster.job_cls

I am hoping that this PR cleans up a few things. This could probably be cleaned up further so suggestions more than welcome !

@guillaumeeb

Copy link
Copy Markdown
Member

Would have need this explanations!

Also the *Cluster uses the *Job default config_name

I understand the idea, but it feels slightly weird.

This is a really small concern though, I'm happy to keep it so as I've no good suggestion to offer.

@guillaumeeb guillaumeeb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lesteve, it's OK for me to merge this one.

@lesteve

lesteve commented Nov 21, 2019

Copy link
Copy Markdown
Member Author

OK let's merge this one then!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interface not loaded from config file

2 participants